(ns webcrawler.test.testcore
  (:use [webcrawler.core])
  (:use [clojure.test]))

(def test-file-loc "test-file.txt")
(def test-file (read-seq-from-file test-file-loc))
(def test-write-file-loc "write-file.txt")


(deftest crawlable
  (is (= true (crawlable? "http://oracle.com/index.html")))
  (is (= false (crawlable? "http://www.youtube.com/watch?v=CNK74LISdUk&feature=player_embedded"))))

(deftest pdf
  (is (= "http://www.oracle.com/us/corporate/customers/sgi-aia-snapshot-168057.pdf" (pdf? "http://www.oracle.com/us/corporate/customers/sgi-aia-snapshot-168057.pdf")))
  (is (= nil (pdf? "http://master.fon.rs"))))

(deftest req
  (is (= true (instance? clojure.lang.Agent (request "http://oracle.com/index.html")))))

(deftest read-seq
 (is (= true (.equals "works" (first test-file)))))

(deftest write-seq
  (write-seq-to-file [1 2 3] test-write-file-loc true)
  (def test-write-file (read-seq-from-file test-write-file-loc))
  (def a ["1" "2" "3"])
  (is (= (seq a) test-write-file)))

(deftest failed-ag 
  (is (= true (failed-agt (request "http://www.oracle.com/error.html")))))

